@extends('layouts.admin')
@section('content')
    @include('permission.nav')
    <form action="{{route('site.permission.update',[$site,$role])}}" method="post">
    @csrf
    @method('put')

    @forelse($modules as $module)
        <div class="card">
            <div class="card-header">
                {{$module['title']}}

            </div>

                <div class="card-body">
                <div class="bg-white p-3 shadow-sm border rounded">
                    @foreach($module['menus'] as $menu)
                        <h6>{{$menu['title']}}</h6>
                        <div class="row mb-3 border-bottom pb-3">
                            @foreach($menu['items'] as $item)
                                <div class="col-6 col-sm-3">
                                    <label>
                                        <input type="checkbox" name="permissions[]" value="{{permission_name($item['permission'],$site,$module)}}"
                                            {{$role->hasPermissionTo(permission_name($item['permission'],$site,$module)) ? 'checked':''}}>
                                        {{$item['title']}}<small>{{$item['permission']}}</small>
                                    </label>
                                </div>
                            @endforeach
                        </div>

                    @endforeach
                </div>
            </div>
        </div>
            <button class="btn btn-primary mt-3">保存</button>

        @empty
        <div class="text-secondary mb-3 text-center p-3 border shadow-sm rounded">
            <i class="fa fa-info-circle" aria-hidden="true"></i>当前站点没有任何模块，请联系管理员 <strong>{{$site->master->name}}</strong>
        </div>

    @endforelse
    </form>
@endsection
